import java.util.Scanner;

public class Demo1 {
    public static int func(String str1,String str2) {
        char[] arr1 = str1.toCharArray();
        char[] arr2 = str2.toCharArray();

        int len1 = arr1.length;
        int len2 = arr2.length;

        int[][] array = new int[len1+1][len2+1];
        int maxLen = 0;

        for(int i = 1; i <= len1; i++) {
            for(int j = 1; j <= len2; j++) {
                if(arr1[i- 1] == arr2[j - 1]) {
                    array[i][j] = array[i-1][j-1] + 1;

                    if(array[i][j] > maxLen) {
                        maxLen = array[i][j];
                    }
                }
            }
        }

        return maxLen;
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.nextLine();
        String str2 = scan.nextLine();

        if(str1.length() <str2.length()) {
            System.out.println(func(str1,str2));
        }else {
            System.out.println(func(str2,str1));
        }

    }
}
